package com.dragon.mmochat.message;

import java.util.ArrayList;
import java.util.List;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.role.MmochatFriend;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.skymobi.buffer.SkymobiBuffer;
import com.skymobi.message.SkymobiProtocolMessage;

public class Mmochat_10_2S extends SkymobiProtocolMessage {
	MmochatPlayer me;
	List<MmochatFriend> adds = new ArrayList<MmochatFriend>();
	List<MmochatFriend> dels = new ArrayList<MmochatFriend>();

	public Mmochat_10_2S() {
		setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_10_2);
	}

	@Override
	protected void encodeBody(SkymobiBuffer out) {
		out.putShort((short) adds.size());
		for (MmochatFriend friend : adds) {
			out.putInt(friend.getRoleId());
			out.putInt(friend.getFriendListPrority());
			out.putUnsignedShort(friend.getBmpId());
			if (friend.isVip()) {
				out.put((byte) 1);
			} else {
				out.put((byte) 0);
			}
			out.put((byte) friend.getFriendState(me));
			out.putPrefixedString(friend.getName(), 1);
		}
		out.putShort((short) dels.size());
		for (MmochatFriend friend : dels) {
			out.putInt(friend.getRoleId());
		}
	}

	public void setAdds(List<MmochatFriend> adds) {
		this.adds = adds;
	}

	public void setDels(List<MmochatFriend> dels) {
		this.dels = dels;
	}

	public void setMe(MmochatPlayer me) {
		this.me = me;
	}

}
